X-Git-Url: http://git.cyclocoop.org//%22http:/%22.attribut_html%28%24lesurls%5B%24numero%5D%29.%22/%22?a=blobdiff_plain;f=includes%2Ffilerepo%2FFileRepo.php;h=d4eef8704fcf4606ff0e95a5b779c7b0544a30b7;hb=250da851d1ab6d01a7c53a6e947b699e54b4b470;hp=6533daec9836b7ddc89a9b49d68f9cf887573de4;hpb=3d7f9d6fee486a2bd8dd5037bb0d2dac9c57644d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 6533daec98..d4eef8704f 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -60,7 +60,11 @@ class FileRepo { var $oldFileFactory = false; var $fileFactoryKey = false, $oldFileFactoryKey = false; - function __construct( array $info = null ) { + /** + * @param $info array|null + * @throws MWException + */ + public function __construct( array $info = null ) { // Verify required settings presence if( $info === null @@ -114,11 +118,11 @@ class FileRepo { : array(); // Give defaults for the basic zones... foreach ( array( 'public', 'thumb', 'temp', 'deleted' ) as $zone ) { - if ( !isset( $this->zones[$zone] ) ) { - $this->zones[$zone] = array( - 'container' => "{$this->name}-{$zone}", - 'directory' => '' // container root - ); + if ( !isset( $this->zones[$zone]['container'] ) ) { + $this->zones[$zone]['container'] = "{$this->name}-{$zone}"; + } + if ( !isset( $this->zones[$zone]['directory'] ) ) { + $this->zones[$zone]['directory'] = ''; } } } @@ -146,6 +150,7 @@ class FileRepo { * Check if a single zone or list of zones is defined for usage * * @param $doZones Array Only do a particular zones + * @throws MWException * @return Status */ protected function initZones( $doZones = array() ) { @@ -186,7 +191,7 @@ class FileRepo { * The suffix, if supplied, is considered to be unencoded, and will be * URL-encoded before being returned. * - * @param $suffix string + * @param $suffix string|bool * @return string */ public function getVirtualUrl( $suffix = false ) { @@ -204,6 +209,11 @@ class FileRepo { * @return String or false */ public function getZoneUrl( $zone ) { + if ( isset( $this->zones[$zone]['url'] ) + && in_array( $zone, array( 'public', 'temp', 'thumb' ) ) ) + { + return $this->zones[$zone]['url']; // custom URL + } switch ( $zone ) { case 'public': return $this->url; @@ -223,6 +233,7 @@ class FileRepo { * Use this function wisely. * * @param $url string + * @throws MWException * @return string */ public function resolveVirtualUrl( $url ) { @@ -433,6 +444,7 @@ class FileRepo { * SHA-1 content hash. * * STUB + * @param $hash * @return array */ public function findBySha1( $hash ) { @@ -442,10 +454,11 @@ class FileRepo { /** * Get the public root URL of the repository * + * @deprecated since 1.20 * @return string */ public function getRootUrl() { - return $this->url; + return $this->getZoneUrl( 'public' ); } /** @@ -684,6 +697,7 @@ class FileRepo { * self::OVERWRITE_SAME Overwrite the file if the destination exists and has the * same contents as the source * self::SKIP_LOCKING Skip any file locking when doing the store + * @throws MWException * @return FileRepoStatus */ public function storeBatch( array $triplets, $flags = 0 ) { @@ -762,7 +776,7 @@ class FileRepo { * Each file can be a (zone, rel) pair, virtual url, storage path. * It will try to delete each file, but ignores any errors that may occur. * - * @param $pairs array List of files to delete + * @param $files array List of files to delete * @param $flags Integer: bitwise combination of the following flags: * self::SKIP_LOCKING Skip any file locking when doing the deletions * @return FileRepoStatus @@ -841,7 +855,7 @@ class FileRepo { * This function can be used to write to otherwise read-only foreign repos. * This is intended for copying generated thumbnails into the repo. * - * @param $src Array List of tuples (file system path, virtual URL or storage path) + * @param $pairs Array List of tuples (file system path, virtual URL or storage path) * @return FileRepoStatus */ public function quickImportBatch( array $pairs ) { @@ -852,14 +866,11 @@ class FileRepo { $operations[] = array( 'op' => 'store', 'src' => $src, - 'dst' => $this->resolveToStoragePath( $dst ), - 'overwrite' => true + 'dst' => $this->resolveToStoragePath( $dst ) ); $this->backend->prepare( array( 'dir' => dirname( $dst ) ) ); } - $status->merge( $this->backend->doOperations( $operations, - array( 'force' => 1, 'nonLocking' => 1, 'allowStale' => 1, 'nonJournaled' => 1 ) - ) ); + $status->merge( $this->backend->doQuickOperations( $operations ) ); return $status; } @@ -869,7 +880,7 @@ class FileRepo { * This function can be used to write to otherwise read-only foreign repos. * This does no locking nor journaling and is intended for purging thumbnails. * - * @param $path Array List of virtual URLs or storage paths + * @param $paths Array List of virtual URLs or storage paths * @return FileRepoStatus */ public function quickPurgeBatch( array $paths ) { @@ -882,9 +893,7 @@ class FileRepo { 'ignoreMissingSource' => true ); } - $status->merge( $this->backend->doOperations( $operations, - array( 'force' => 1, 'nonLocking' => 1, 'allowStale' => 1, 'nonJournaled' => 1 ) - ) ); + $status->merge( $this->backend->doQuickOperations( $operations ) ); return $status; } @@ -1013,6 +1022,7 @@ class FileRepo { * @param $triplets Array: (source, dest, archive) triplets as per publish() * @param $flags Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate * that the source files should be deleted if possible + * @throws MWException * @return FileRepoStatus */ public function publishBatch( array $triplets, $flags = 0 ) { @@ -1188,6 +1198,7 @@ class FileRepo { * is a two-element array containing the source file path relative to the * public root in the first element, and the archive file path relative * to the deleted zone root in the second element. + * @throws MWException * @return FileRepoStatus */ public function deleteBatch( array $sourceDestPairs ) { @@ -1257,6 +1268,7 @@ class FileRepo { * Get a relative path for a deletion archive key, * e.g. s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg * + * @param $key string * @return string */ public function getDeletedHashPath( $key ) { @@ -1460,6 +1472,7 @@ class FileRepo { /** * Create a new good result * + * @param $value null|string * @return FileRepoStatus */ public function newGood( $value = null ) {